package com.qxkj.mysql.multidb.dbRoute.base;

/**
 * Copyright © 2018年 ziniuxiaozhu. All rights reserved.
 *
 * @Author 临江仙 hzqiuxm@163.com
 * 动态数据源实现中KEY的存放工具类
 * @Date 2018/9/4 20:41
 */
public class DbContextHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
    private static final ThreadLocal<String> tableIndexHolder= new ThreadLocal<String>();


    public static void setDbKey(String dbKey) {
        contextHolder.set(dbKey);
    }

    public static String getDbKey() {
        return (String) contextHolder.get();
    }

    public static void clearDbKey() {
        contextHolder.remove();
    }

    public static void setTableIndex(String tableIndex){
        tableIndexHolder.set(tableIndex);
    }

    public static String getTableIndex(){
        return (String) tableIndexHolder.get();
    }
    public static void clearTableIndex(){
        tableIndexHolder.remove();
    }
}
